home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / lysrc.zip / YYLEX.COD < prev    next >
Text File  |  1993-01-24  |  1KB  |  81 lines

  1.  
  2. (* lexical analyzer template (TP Lex V3.0), V1.0 3-2-91 AG *)
  3.  
  4. (* global definitions: *)
  5. %%
  6.  
  7. function yylex : Integer;
  8.  
  9. procedure yyaction ( yyruleno : Integer );
  10.   (* local definitions: *)
  11. %%
  12. begin
  13.   (* actions: *)
  14.   case yyruleno of
  15. %%
  16.   end;
  17. end(*yyaction*);
  18.  
  19. (* DFA table: *)
  20. %%
  21.  
  22. var yyn : Integer;
  23.  
  24. label start, scan, action;
  25.  
  26. begin
  27.  
  28. start:
  29.  
  30.   (* initialize: *)
  31.  
  32.   yynew;
  33.  
  34. scan:
  35.  
  36.   (* mark positions and matches: *)
  37.  
  38.   for yyn := yykl[yystate] to     yykh[yystate] do yymark(yyk[yyn]);
  39.   for yyn := yymh[yystate] downto yyml[yystate] do yymatch(yym[yyn]);
  40.  
  41.   if yytl[yystate]>yyth[yystate] then goto action; (* dead state *)
  42.  
  43.   (* get next character: *)
  44.  
  45.   yyscan;
  46.  
  47.   (* determine action: *)
  48.  
  49.   yyn := yytl[yystate];
  50.   while (yyn<=yyth[yystate]) and not (yyactchar in yyt[yyn].cc) do inc(yyn);
  51.   if yyn>yyth[yystate] then goto action;
  52.     (* no transition on yyactchar in this state *)
  53.  
  54.   (* switch to new state: *)
  55.  
  56.   yystate := yyt[yyn].s;
  57.  
  58.   goto scan;
  59.  
  60. action:
  61.  
  62.   (* execute action: *)
  63.  
  64.   if yyfind(yyrule) then
  65.     begin
  66.       yyaction(yyrule);
  67.       if yyreject then goto action;
  68.     end
  69.   else if not yydefault and yywrap then
  70.     begin
  71.       yyclear;
  72.       return(0);
  73.     end;
  74.  
  75.   if not yydone then goto start;
  76.  
  77.   yylex := yyretval;
  78.  
  79. end(*yylex*);
  80.  
  81.